home *** CD-ROM | disk | FTP | other *** search
/ Commodore Disk User Volume 4 #11 / Commodore_Disk_User_Vol.4_11_1991_-.d64 / 8 way scroll asm (.txt) < prev    next >
Commodore BASIC  |  2022-10-26  |  7KB  |  427 lines

  1. 10 *=49152
  2. 11 !
  3. 12 ! disable interupts,set up
  4. 13 ! interupt vector,enable raster
  5. 14 ! interupt,set up vic banks,
  6. 15 ! disable hardware timer a,
  7. 16 ! re-enable interupts.
  8. 17 !
  9. 20 setint sei
  10. 30 lda #<intr
  11. 40 sta 788
  12. 50 lda #>intr
  13. 60 sta 789
  14. 70 lda 53274
  15. 80 ora #1
  16. 90 sta 53274
  17. 100 lda 53265
  18. 110 and #127
  19. 120 sta 53265
  20. 130 lda #252
  21. 140 sta 53266
  22. 150 lda 56578
  23. 160 ora #3
  24. 170 sta 56578
  25. 180 lda 56576
  26. 190 and #252
  27. 200 ora #2
  28. 210 sta 56576
  29. 220 lda 56334
  30. 230 and #254
  31. 240 sta 56334
  32. 250 cli
  33. 251 !
  34. 252 ! set screen colours,
  35. 253 ! set start values to be
  36. 254 ! stored in map & map+1
  37. 255 ! (see window)
  38. 256 !
  39. 260 lda #0
  40. 270 sta 53280
  41. 280 sta 53281
  42. 290 lda #<32768
  43. 300 sta map
  44. 310 lda #>32768
  45. 320 sta map+1
  46. 997 !
  47. 998 rts
  48. 1000 !
  49. 1001 ! check to see if a scroll
  50. 1002 ! is taking place.if not jump
  51. 1003 ! to 'noscroll' otherwise
  52. 1004 ! check to see which of the 8
  53. 1005 ! possible directions we are
  54. 1006 ! scrolling in and process.
  55. 1007 !
  56. 1020 intr lda way
  57. 1030 beq noscroll
  58. 1040 cmp #1
  59. 1050 bne w1
  60. 1060 jsr ysub
  61. 1070 jmp noscroll
  62. 1080 w1 cmp #2
  63. 1090 bne w2
  64. 1100 jsr yadd
  65. 1110 jmp noscroll
  66. 1120 w2 cmp #3
  67. 1130 bne w3
  68. 1140 jsr xsub
  69. 1150 jmp noscroll
  70. 1160 w3 cmp #4
  71. 1170 bne w4
  72. 1179 jsr xadd
  73. 1180 jmp noscroll
  74. 1181 w4 cmp #5
  75. 1182 bne w5
  76. 1183 jsr xadd
  77. 1184 jsr ysub
  78. 1185 jmp noscroll
  79. 1186 w5 cmp #6
  80. 1187 bne w6
  81. 1188 jsr ysub
  82. 1189 jsr xsub
  83. 1190 jmp noscroll
  84. 1191 w6 cmp #7
  85. 1192 bne w7
  86. 1193 jsr yadd
  87. 1194 jsr xadd
  88. 1195 jmp noscroll
  89. 1196 w7 cmp #8
  90. 1197 bne noscroll
  91. 1198 jsr yadd
  92. 1199 jsr xsub
  93. 1200 !
  94. 1210 ! set up location of raster
  95. 1211 ! split and re-vector the
  96. 1212 ! interupt to process the
  97. 1213 ! status line (non moving
  98. 1214 ! screen) routine.
  99. 1215 !
  100. 1240 noscroll lda #<statline
  101. 1250 sta 788
  102. 1260 lda #>statline
  103. 1270 sta 789
  104. 1280 lda raster
  105. 1290 sta 53266
  106. 1300 jmp exint
  107. 1301 !
  108. 1302 ! set 40 column screen,
  109. 1303 ! clear scroll registers to
  110. 1304 ! ensure this section of the
  111. 1305 ! screen is still,re-vector
  112. 1306 ! the interupt to process the
  113. 1307 ! routine dealing with the
  114. 1308 ! scrolling section of the
  115. 1309 ! screen,jsr to 'control' routine
  116. 1310 !
  117. 1315 statline lda #8
  118. 1320 sta 53270
  119. 1330 lda #23
  120. 1340 sta 53265
  121. 1350 lda #54
  122. 1360 sta 53272
  123. 1370 lda #<gamearea
  124. 1380 sta 788
  125. 1390 lda #>gamearea
  126. 1400 sta 789
  127. 1405 lda #7
  128. 1406 sta 53280
  129. 1410 jsr control
  130. 1415 lda #0
  131. 1416 sta 53280
  132. 1420 lda #252
  133. 1430 sta 53266
  134. 1440 jmp exint
  135. 1441 !
  136. 1442 ! set 38 column,24 row screen
  137. 1443 ! print up screen from
  138. 1444 ! map & map+1,set values of
  139. 1445 ! scroll registers.
  140. 1446 !
  141. 1450 gamearea lda 53270
  142. 1455 and #0
  143. 1456 ora #16
  144. 1470 ora xscroll
  145. 1480 sta 53270
  146. 1490 lda 53265
  147. 1500 and #248
  148. 1510 ora yscroll
  149. 1520 sta 53265
  150. 1610 lda #36
  151. 1620 sta 53272
  152. 1625 lda #6
  153. 1626 sta 53280
  154. 1650 jsr window
  155. 1651 lda #0
  156. 1652 sta 53280
  157. 1654 jmp intr
  158. 1655 !
  159. 1656 ! signal that interupt has been
  160. 1657 ! processed,restore registers
  161. 1658 ! and return from interupt.
  162. 1659 !
  163. 1660 exint lda #1
  164. 1670 sta $d019
  165. 1690 pla
  166. 1700 tay
  167. 1710 pla
  168. 1720 tax
  169. 1730 pla
  170. 1740 rti
  171. 1741 !
  172. 1742 ! hardware scroll screen 1 pixel
  173. 1743 ! to the right.if screen has
  174. 1744 ! moved more than 1 char. then
  175. 1745 ! subtract 1 from 16 bit value in
  176. 1746 ! map & map+1.
  177. 1747 !
  178. 1750 xadd lda 53270
  179. 1760 ora #248
  180. 1770 clc
  181. 1780 adc xspeed
  182. 1790 and #7
  183. 1800 sta xscroll
  184. 1810 bcc exxadd
  185. 1820 sec
  186. 1830 lda map
  187. 1840 sbc #1
  188. 1850 sta map
  189. 1860 lda map+1
  190. 1870 sbc #0
  191. 1880 sta map+1
  192. 1960 exxadd rts
  193. 1961 !
  194. 1962 ! hardware scroll screen 1 pixel
  195. 1963 ! to the left.if screen has
  196. 1964 ! moved more than 1 char. then
  197. 1965 ! add 1 to 16 bit value
  198. 1966 ! in map & map+1.
  199. 1967 !
  200. 1970 xsub lda 53270
  201. 1980 and #7
  202. 1990 sec
  203. 2000 sbc xspeed
  204. 2010 and #7
  205. 2020 sta xscroll
  206. 2030 bcs exxsub
  207. 2040 clc
  208. 2050 lda map
  209. 2060 adc #1
  210. 2070 sta map
  211. 2080 lda map+1
  212. 2090 adc #0
  213. 2100 sta map+1
  214. 2180 exxsub rts
  215. 2181 !
  216. 2182 ! hardware scroll the screen
  217. 2183 ! down 1 pixel. if screen has
  218. 2184 ! moved more than 1 char then
  219. 2185 ! subtract number of screens
  220. 2186 ! horizontally in map multiplyed
  221. 2187 ! by 40 from 16 bit value in
  222. 2188 ! map & map+1.
  223. 2189 ! eg:-
  224. 2190 ! if there are 6 screen across
  225. 2191 ! in map then subtract 240.
  226. 2192 !
  227. 2199 yadd lda 53265
  228. 2200 ora #248
  229. 2210 clc
  230. 2220 adc yspeed
  231. 2230 and #7
  232. 2240 sta yscroll
  233. 2250 bcc exyadd
  234. 2260 sec
  235. 2270 lda map
  236. 2280 sbc #240
  237. 2290 sta map
  238. 2300 lda map+1
  239. 2310 sbc #0
  240. 2320 sta map+1
  241. 2400 exyadd rts
  242. 2401 !
  243. 2402 ! as above but scroll up 1 pixel
  244. 2403 ! and add same value if
  245. 2404 ! necessary.
  246. 2405 !
  247. 2410 ysub lda 53265
  248. 2420 and #7
  249. 2430 sec
  250. 2440 sbc yspeed
  251. 2450 and #7
  252. 2460 sta yscroll
  253. 2470 bcs exysub
  254. 2480 clc
  255. 2490 lda map
  256. 2500 adc #240
  257. 2510 sta map
  258. 2520 lda map+1
  259. 2530 adc #0
  260. 2540 sta map+1
  261. 2620 exysub rts
  262. 4000 !
  263. 4001 ! (see diagram 1 ):-
  264. 4002 ! print up 1000 bytes to screen,
  265. 4003 ! ( screen is at 17408),
  266. 4004 ! starting at memory location
  267. 4005 ! pointed at by values in
  268. 4006 ! map & map+1.
  269. 4007 !
  270. 4070 window lda #<18432
  271. 4080 sta 253
  272. 4090 lda #>18432
  273. 4100 sta 254
  274. 4120 lda map
  275. 4130 sta 251
  276. 4140 lda map+1
  277. 4150 sta 252
  278. 4160 ldx #18
  279. 4180 windloop1 ldy #0
  280. 4190 windloop2 lda (251),y
  281. 4200 sta (253),y
  282. 4210 iny
  283. 4215 cpy #40
  284. 4220 bne windloop2
  285. 4230 lda 251
  286. 4240 clc
  287. 4250 adc #240
  288. 4260 sta 251
  289. 4270 bcc windlp2
  290. 4290 inc 252
  291. 4300 windlp2 lda 253
  292. 4310 clc
  293. 4320 adc #40
  294. 4330 sta 253
  295. 4340 bcc excal
  296. 4360 inc 254
  297. 4370 excal dex
  298. 4376 bne windloop1
  299. 4390 rts
  300. 4400 !
  301. 4410 ! variables as follows :-
  302. 4411 !
  303. 4412 ! 1 - lo,hi address of screen
  304. 4413 ! (row 0,column 0) in overall map
  305. 4414 ! 2 - posistion of raster split
  306. 4415 ! 3 - speed of x scroll
  307. 4416 ! 4 - speed of y scroll
  308. 4417 ! 5 - value of x scroll register
  309. 4418 ! 6 - value of y scroll register
  310. 4419 ! 7 - joystick x value
  311. 4420 ! 8 - joystick y value
  312. 4421 ! 9 - direction of scroll (0-8)
  313. 4422 !
  314. 6000 map byt <32768,>32768
  315. 6030 raster byt 189
  316. 6060 xspeed byt 1
  317. 6070 yspeed byt 1
  318. 6080 xscroll byt 0
  319. 6090 yscroll byt 0
  320. 6100 dx byt 0
  321. 6110 dy byt 0
  322. 6160 way byt 0
  323. 6161 !
  324. 6162 ! the values in way indicate
  325. 6163 ! the follwing:-
  326. 6164 !
  327. 6165 ! 0 = no scrolling
  328. 6166 ! 1 = scroll up
  329. 6167 ! 2 = scroll down
  330. 6168 ! 3 = scroll left
  331. 6169 ! 4 = scroll right
  332. 6170 ! 5 = scroll up & right
  333. 6171 ! 6 = scroll up & left
  334. 6172 ! 7 = scroll down & right
  335. 6173 ! 8 = scroll down & left
  336. 6174 !
  337. 6179 !
  338. 6180 ! joystick reading routine.
  339. 6181 ! see page 345 of programmers
  340. 6182 ! reference guide for full
  341. 6183 ! explanation.
  342. 6184 !
  343. 7000 joyread lda 56320
  344. 7010 ldy #0
  345. 7020 ldx #0
  346. 7025 !
  347. 7030 lsr a
  348. 7040 bcs joy0
  349. 7050 dey
  350. 7060 joy0 lsr a
  351. 7070 bcs joy1
  352. 7080 iny
  353. 7090 joy1 lsr a
  354. 7100 bcs joy2
  355. 7110 dex
  356. 7120 joy2 lsr a
  357. 7130 bcs joy3
  358. 7140 inx
  359. 7150 joy3 lsr a
  360. 7160 stx dx
  361. 7170 sty dy
  362. 7180 rts
  363. 7190 !
  364. 7191 ! main control routine :-
  365. 7192 ! decide which direction to
  366. 7193 ! scroll.
  367. 7194 !
  368. 8000 control jsr joyread
  369. 8010 ldx dx
  370. 8020 ldy dy
  371. 8021 txa
  372. 8022 bne vertical
  373. 8023 tya
  374. 8024 bne vertical
  375. 8025 sta way
  376. 8026 rts
  377. 8030 vertical cpx #0
  378. 8040 bne horizontal
  379. 8050 upc cpy #255
  380. 8060 bne downc
  381. 8070 lda #2
  382. 8080 sta way
  383. 8090 rts
  384. 8100 downc cpy #1
  385. 8110 bne xvert
  386. 8120 lda #1
  387. 8130 sta way
  388. 8140 xvert rts
  389. 8150 horizontal cpy #0
  390. 8160 bne dia(NULL)nal
  391. 8170 leftc cpx #255
  392. 8180 bne rightc
  393. 8190 lda #4
  394. 8200 sta way
  395. 8210 rts
  396. 8220 rightc cpx #1
  397. 8230 bne outcon
  398. 8240 lda #3
  399. 8250 sta way
  400. 8260 outcon rts
  401. 8270 dia(NULL)nal cpy #255
  402. 8280 bne diagdown
  403. 8290 cpx #1
  404. 8300 bne uplft
  405. 8310 uprght lda #8
  406. 8320 sta way
  407. 8330 rts
  408. 8340 uplft cpx #255
  409. 8350 bne outcon
  410. 8360 lda #7
  411. 8370 sta way
  412. 8380 rts
  413. 8390 diagdown cpy #1
  414. 8400 bne xdiag
  415. 8410 cpx #1
  416. 8420 bne dwnlft
  417. 8440 dwnrght lda #6
  418. 8450 sta way
  419. 8460 rts
  420. 8470 dwnlft cpx #255
  421. 8480 bne xdiag
  422. 8490 lda #5
  423. 8500 sta way
  424. 8510 xdiag rts
  425. 8520 !
  426. 8530 end
  427.